﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Media.Imaging;
using PlaneWar.Controls;

namespace PlaneWar.Helper
{
    public class EnemyPlane_Helper : INotifyPropertyChanged
    {
        public Control_EnemyPlane view;
        public EnemyPlane_Helper(double x, double y, int blood, BitmapImage planeSize, double v, Control_EnemyPlane view, double w, double h, string names)
        {
            this.Top = y;   //y轴
            this.Left = x;   //X轴
            this.v = v;   //速度
            this.planeSize = planeSize;   //飞机类型
            this.view = view;   //页面
            this.width = w;
            this.height = h;
            this.Tmp_blood = blood;
            this.Blood = blood;   //血液（生命）
            this.Mian_Name = names;
            view.DataContext = this;
            isDead = false;   //
        }
        //储存创建角色的总血液(飞机等级)
        public double Tmp_blood;

        private double v;
        public bool isDead;
        public string Mian_Name;

        public int MyProperty { get; set; }

        private double top;
        public double Top
        {
            get { return top; }
            set { top = value; OnPropertyChanged("Top"); }
        }

        private double left;
        public double Left
        {
            get { return left; }
            set { left = value; OnPropertyChanged("Left"); }
        }

        //Imge\1.png
        private BitmapImage planeSize;
        public BitmapImage PlaneSize
        {
            get { return planeSize; }
            set
            {
                planeSize = value; OnPropertyChanged("PlaneSize");
            }
        }

        private int blood;
        public int Blood
        {
            get { return blood; }
            set
            {
                blood = value;
                if (Tmp_blood == value)
                {
                    this.Blood_W = this.width;
                }
                else if (value != 0)
                {
                    this.Blood_W = this.width * (value / Tmp_blood);
                }
                OnPropertyChanged("Blood");
            }
        }

        //页面血液进度条长度
        private double blood_W;
        public double Blood_W
        {
            get { return blood_W; }
            set { blood_W = value; OnPropertyChanged("Blood_W"); }
        }

        private System.Windows.Visibility vis;
        public System.Windows.Visibility Vis
        {
            get { return vis; }
            set { vis = value; OnPropertyChanged("Vis"); }
        }

        private double width;
        public double Width_
        {
            get { return width; }
            set { width = value; OnPropertyChanged("Width_"); }
        }

        private double height;
        public double Height_
        {
            get { return height; }
            set { height = value; OnPropertyChanged("Height_"); }
        }

        public void run()
        {
            if (this.top >= 500)
            {
                this.isDead = true;
                this.Vis = System.Windows.Visibility.Collapsed;
                return;
            }
            this.Top += v;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string arg)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(arg));
            }
        }

    }
}
